package top.codedance.iotp.simulator.serialPort.srs.opw;

import top.codedance.iotp.common.util.BytesBuilder;
import top.codedance.iotp.common.util.HexCodec;
import top.codedance.iotp.common.util.IEEE754.IEEE754Util;
import top.codedance.iotp.simulator.serialPort.srs.Simulator;

import java.util.ArrayList;
import java.util.List;

//维德路特液位仪模拟器
public class VeederRoot implements Simulator {
    @Override
    public List<BytesBuilder> exec(byte[] cmd) {
        List<BytesBuilder> results = new ArrayList<>();
        HexCodec hc = new HexCodec();
        String command = hc.toHex(cmd).replaceAll("\\s+", "").toUpperCase();
        // 报警数据
        BytesBuilder bb = new BytesBuilder();
        StringBuilder sb = new StringBuilder();
        sb.append("01693230363030".getBytes());
        sb.append("17".getBytes());
        sb.append("04".getBytes());
        sb.append("14".getBytes());
        sb.append("16".getBytes());
        sb.append("32".getBytes());

        sb.append("01".getBytes());
        sb.append("01".getBytes());
        sb.append("1704141632".getBytes());
        sb.append("0001".getBytes());

        bb.append(sb.toString().getBytes());
        StringBuilder sb1 = new StringBuilder();
        sb1.append("02".getBytes());
        sb1.append("02".getBytes());
        sb1.append("1704141632".getBytes());
        sb1.append("0002".getBytes());
        sb1.append("03".getBytes());
        sb1.append("0020".getBytes());
        sb1.append("03".getBytes());
        bb.append(sb1.toString().getBytes());
        results.add(bb);
        return results;
    }

    public static void main(String[] args) {
        byte[] bytes1 = IEEE754Util.float2hex(1200);
        System.out.println(bytes1);
        System.err.println(IEEE754Util.hex2float(bytes1, true));
    }
}
